<template>
  <div class="loader-base" v-if="showLoad"><div class="loader-wrap"></div></div>
</template>

<script>
export default {
  name: "scanbridge",
  data() {
    return {
      showLoad:false,
    };
  },
  created() {
    this.getData();
  },
  computed: {
    userinfo() {
      if (localStorage.UserInfo) {
        return JSON.parse(localStorage.UserInfo);
      }
    }
  },
  methods: {
    getData(){
      var self = this, 
          BBillGuid = this.$route.query.id;
      // alert(BBillGuid)
      self.showLoad = true;
      if(this.userinfo != null && this.userinfo != '')
      {
        var query = {
          Guid: BBillGuid
        };
        this.Ajax.post("GetOrderDetail", query).then(function(resp) {
          self.showLoad = false;
          if (resp.IsSuccess && resp.Data != null) {
            if(resp.Data.Main.CargoOwnerGuid != self.userinfo.BelongGuid){
              self.$vux.alert.show({
                title: '提示',
                content: '该订单不属于您，请核对后再进行扫描签收',
                onHide(){
                  self.$router.replace({
                    path: "/login",
                  });
                }
              });
            } else {
              self.$router.replace({
                  path: "/login",
                  query: { bbillGuid: BBillGuid },
              });
            }
          } else {
            self.$vux.alert.show({
              title: '提示',
              content: '订单信息不存在，请重新扫码',
              onHide(){
                self.$router.replace({
                  path: "/login",
                });
              }
            });
          } 
        });
      }
      else
      {
        self.$router.replace({
            path: "/login",
            query: { bbillGuid: BBillGuid },
        });
      }
    }
  }
};
</script>